package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallCustomerLicenseMapper;
import org.linlinjava.litemall.db.domain.LitemallCustomer;
import org.linlinjava.litemall.db.domain.LitemallCustomerLicense;
import org.linlinjava.litemall.db.domain.LitemallCustomerLicenseExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LitemallCustomerLicenseService {
    @Resource
    LitemallCustomerLicenseMapper mapper;

    public void insert(LitemallCustomerLicense license) {
        mapper.insertSelective(license);
    }

    public LitemallCustomerLicense getById(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    public LitemallCustomerLicense findByLicenseFile(String path) {
        LitemallCustomerLicenseExample example = new LitemallCustomerLicenseExample();
        example.or().andLicenseFileEqualTo(path);
        return mapper.selectOneByExample(example);
    }

    public LitemallCustomerLicense getByUserId(Long id) {
        LitemallCustomerLicenseExample example = new LitemallCustomerLicenseExample();
        example.or().andCustomerIdEqualTo(id);
        return mapper.selectOneByExample(example);
    }
}
